﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Collections;
using GPCSC.Webs;
using ExtAspNet;



namespace GPCSC.Web.sjs
{
    public partial class Ucount : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadData();
            }
        }
        private void LoadData()
        {
            // 模拟从数据库返回数据表
            try
            {
                Hashtable htable = new Hashtable();
                DataSet ds = new DataReturn().ReturnData(htable, "sel_POST_all");

                Grid1.DataSource = ds;
                Grid1.DataBind();
            }
            catch (Exception ee)
            {
                throw (ee);
            }
        }

        protected void Grid1_PageIndexChange(object sender, ExtAspNet.GridPageEventArgs e)
        {
            Grid1.PageIndex = e.NewPageIndex;

            LoadData();
        }




        protected void btnDelete_Click(object sender, EventArgs e)
        {
            GPCSC.Webs.databyhtable dh = new databyhtable();
            Hashtable htable = new Hashtable();
            int count = Grid1.SelectedRowIndexArray.Length;
            if (count > 0)
            {
                foreach (int row in Grid1.SelectedRowIndexArray)
                {
                    htable.Clear();
                    htable.Add("Isdel", 1);
                    dh.databyhtables(htable, "update", "CL_POST_S", "CL_POST_SOID", Grid1.DataKeys[row][0].ToString());
                }
            }
            LoadData();
            Alert.Show("删除成功！");
        }
        protected void Window1_Close(object sender, EventArgs e)
        {

            LoadData();
        }
        protected void ttbSearch_Trigger1Click(object sender, EventArgs e)
        {
            LoadData();
        }

        protected void ttbSearch_Trigger2Click(object sender, EventArgs e)
        {

            string username = ttbSearch.Text.Trim();
            if (username == "")
            {
                LoadData();
            }
            else
            {
                Hashtable htable = new Hashtable();
                username = "%" + username + "%";
                htable.Add("@like", username);
                DataSet ds = new DataReturn().ReturnData(htable, "sel_POST_bylike");
                Grid1.DataSource = ds.Tables[0];
                Grid1.DataBind();

            }
        }
    }
}